//
//  HJChatLeftMsgCell.m
//  project
//
//  Created by hu on 2019/3/27.
//  Copyright © 2019 健健. All rights reserved.
//

#import "HJChatLeftMsgCell.h"

@interface HJChatLeftMsgCell ()
/*
 * 头像父视图
 */
@property (weak, nonatomic) IBOutlet UIView *headSubView;
/*
 * 头像图片
 */
@property (weak, nonatomic) IBOutlet UIImageView *headImage;

/*
 * 聊天内容
 */
@property (weak, nonatomic) IBOutlet UILabel *contentMsg;


@property (weak, nonatomic) IBOutlet NSLayoutConstraint *contentMsg_Width;

@end
@implementation HJChatLeftMsgCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    // 用户图片 圆角
    [self.headImage rounded:(UIRectCornerAllCorners) radius:20];
    // 图片外的圆环
    [self.headSubView rounded:(UIRectCornerAllCorners) radius:20 borderColor:[UIColor blackColor] borderWidth:1];
    
}

// 发送失败
- (IBAction)sendErrorBtnClicked:(UIButton *)sender {
   
}

/**
 @param data 赋值的方法
 */
-(void)loadLeftMoreWithData:(RCTextMessage *)data {
    self.contentMsg.text = data.content;
//    CGFloat width = SCREEN_WIDTH-85-100;
    CGFloat totalWidth = SCREEN_WIDTH - 140;
    CGSize size = [CommonTools sizeOfText:data.content fontSize:14 width:totalWidth];
//    CGSize size = [CommonTools sizeOfText:data.content fontSize:14 width:184];
    [self.headImage sd_setImageWithURL:[NSURL URLWithString:data.senderUserInfo.portraitUri] placeholderImage:setImage(@"img_mydongtai_defualt_avatar")];

//    NSLog(@"left==%@",NSStringFromCGSize(size));
    CGFloat allWidth = size.width+10;
    if (allWidth<=totalWidth) {
        self.contentMsg_Width.constant = allWidth ;
    }else {
        self.contentMsg_Width.constant = totalWidth;
    }
//    if (size.width<=184) {
//        self.contentMsg_Width.constant = size.width;
//    }else {
//        self.contentMsg_Width.constant = 184;
//    } 
}
@end
